package com.dragon.linkedlist;

import java.util.LinkedList;
import java.util.ListIterator;

/**
 * @author dragon
 * @version V1.0.0-RELEASE
 * @date 2019/5/20 9:14
 */
public class DoubleLinkedListTest {

    public static void main(String[] args) {
        DoubleLinkedList<Integer> linkedList = new DoubleLinkedList<>();
        linkedList.addLast(0);
        linkedList.addLast(1);
        linkedList.addLast(2);
        linkedList.addLast(3);
        linkedList.addLast(4);
        linkedList.addLast(5);
        linkedList.addLast(6);
        System.out.println(linkedList);
        linkedList.add(0, 22);
        linkedList.add(1, 11);
        System.out.println(linkedList);
        linkedList.remove(22);
        linkedList.remove(1);
        System.out.println(linkedList);

        LinkedList<Integer> integers = new LinkedList<>();
        integers.add(1);
        integers.add(2);
        integers.add(3);
        integers.add(4);
        ListIterator<Integer> integerListIterator = integers.listIterator(integers.size());
        while (integerListIterator.hasPrevious()) {
            Integer previous = integerListIterator.previous();
            integerListIterator.remove();
            System.out.println(previous);
        }

    }
}
